package com.hotel.company.service;

import com.hotel.comm.bean.DubboReply;
import com.hotel.comm.bean.IReply;
import com.hotel.comm.bean.company.EjobCompanyPosition;
import com.hotel.comm.service.company.ICompanyPositionService;
import com.hotel.company.repository.IEjobCompanyPositionRepository;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyPositionServiceImpl implements ICompanyPositionService {
    private static final Logger logger = LoggerFactory.getLogger(CompanyPositionServiceImpl.class);
    @Autowired
    private IEjobCompanyPositionRepository companyPositionRepository;

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public IReply findByCityId(Long cityId) {
        List<EjobCompanyPosition> positions = this.companyPositionRepository.findByCityId(cityId);
        logger.info(CollectionUtils.isEmpty(positions) ? "0" : String.valueOf(positions.size()));
        return new DubboReply(true, positions);
    }

}
